// 二次封装axios
import request from "../../utils/request";
import type {SubmitOrder,OrderResponseDate,PayResponseDate,PayReslt,UserInfoResponseData,CertationTypeResponseData,UserParam,UserOrderInfoResponseData,AllUserResponseData,OrderStatueResponseData,AddOrUpdateUser} from "./type"
enum API {
    //提交订单，获取订单号码接口
    SUBMITORDER_URL = '/order/orderInfo/auth/submitOrder/',
    // 获取订单详情数据
    GETORDERINFO_URL='/order/orderInfo/auth/getOrderInfo/',
    // 取消预约
    ORDERCANCEL_URL='/order/orderInfo/auth/cancelOrder/',
    // 获取支付订单二维码接口
    QRCODE_URL = '/order/weixin/createNative/',
    // 查询订单支付的结果
    PAYRERSULT_URL = '/order/weixin/queryPayStatus/',
    // 获取当前用户认证信息
    USERINFO_URL='/user/auth/getUserInfo',
    // 获取证件类型的接口地址
    CERTIFICATIONTYPE_URL='/cmn/dict/findByDictCode/',
    // 用户认证的结构
    USERCERTATION_URL = '/user/auth/userAuah',
    // 获取用户订单号的数据
    USERORDER_URL='/order/orderInfo/auth/',
    // 获取全部就诊人的信息
    ALLUSER_URL='/user/patient/auth/findAll',
    // 获取订单状态
    ORDERSTATE_URL='/order/orderInfo/auth/getStatusList',
    // 获取中国城市的数据
    CITY_URL='/cmn/dict/findByParentId/',
    // 新增就诊人接口
    ADDUSER_URL='/user/patient/auth/save',
    // 修改就诊人信息
    UPDATAUSER_URL='/user/patient/auth/update',
    // 删除就诊人信息
    DELETEUSER_URL='/user/patient/auth/remove/'
}
// 提交订单
export const reqSubitOrder = (hoscode:string,scheduleId:string,patientId:number)=>
request.post<any,SubmitOrder>(API.SUBMITORDER_URL+`${hoscode}/${scheduleId}/${patientId}`)
// 获取订单详情方法
export const reqOrderInfo = (id:string)=>request.get<any,OrderResponseDate>(API.GETORDERINFO_URL+id); 
// 取消订单
export const reqCancelOrder = (id:string)=>request.get(API.ORDERCANCEL_URL+id);
// 获取支付的二维码接口
export const reqQrcode = (orderId:string)=>request.get<any,PayResponseDate>(API.QRCODE_URL+orderId);
// 查询支付订单结果
export const reqQueryPayState = (orderId:string)=>request.get<any,PayReslt>(API.PAYRERSULT_URL+orderId);
// 获取当前用户信息接口
export const reqUserInfo = ()=>request.get<any,UserInfoResponseData>(API.USERINFO_URL);
// 获取证件类型的接口地址
export const reqCertation = (dictCode='CertificatesType')=>request.get<any,CertationTypeResponseData>(API.CERTIFICATIONTYPE_URL+dictCode);
// 用户认证接口
export const reqUserCertation = (data:UserParam) => request.post<any,any>(API.USERCERTATION_URL,data);
// 用户订单号列表的数据
export const reqUserOrderInfo = (page:number,limit:number,patientId:string,orderStatus:string)=>
request.get<any,UserOrderInfoResponseData>(API.USERORDER_URL+`${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`);
// 获取全部就诊人的信息
export const reqAllUser = () => request.get<any,AllUserResponseData>(API.ALLUSER_URL);
// 获取订单接口
export const reqOrederSetate = () => request.get<any,OrderStatueResponseData>(API.ORDERSTATE_URL);
// 获取城市数据
export const reqCity = (parentId:string) => request.get<any,any>(API.CITY_URL+parentId);
// 新增或修改就诊人数据
export const reqAddOrUpdata = (data:AddOrUpdateUser)=>{
    if(data.id){
        return request.put<any,any>(API.UPDATAUSER_URL,data);
    }else{
        return request.post<any,any>(API.ADDUSER_URL,data);
    }
};
// 删除某一个就诊人信息
export const reqRemoveUser = (id:number) => request.delete<any,any>(API.DELETEUSER_URL+id);
